<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.lmpop.trade.ti_discountpolicy.Ti_discountpolicyInfo"%> 
<%@page import="com.lmpop.trade.ts_custclass.*" %>
<%@page import="com.lmpop.trade.ti_voucher.*" %>
<%@page import="com.lmpop.trade.ti_gift.*" %>
<%@ page import="com.lmpop.trade.ti_attach.Ti_attachInfo" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	 
	String user_id="",p_type="",model_id="",s_cust_id="";
 	if(session.getAttribute("session_user_id")!=null){
	     user_id  =session.getAttribute("session_user_id").toString();
	}
	if(request.getParameter("t")!=null && !request.getParameter("t").equals("")){		
		p_type = request.getParameter("t"); 		
	}
	if(request.getParameter("model_id")!=null && !request.getParameter("model_id").equals("")){		
		model_id = request.getParameter("model_id"); 		
	}
	if(request.getParameter("cust_id")!=null && !request.getParameter("cust_id").equals("")){		
		s_cust_id = request.getParameter("cust_id"); 		
	}
	Ti_attachInfo  ti_attachInfo = new Ti_attachInfo(); 
	Ti_giftInfo giftinfo = new Ti_giftInfo(); 
	Map giftinfoMap = new Hashtable();
	giftinfoMap.put("cust_id",s_cust_id);
  List giftlist = giftinfo.getListByPage(giftinfoMap,0,1000);
  
	Map custclassinfoMap = new Hashtable();
	custclassinfoMap.put("class_type","1");
	Ts_custclassInfo custclassinfo = new Ts_custclassInfo();
	String custclass_select =  custclassinfo.getSelectString(custclassinfoMap,"");
%>

<html>
  <head>
    <title>添加优惠策略设置</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="index.js"></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ti_discountpolicyInfo.js'></script>  
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ti_giftInfo.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ti_PaymentRulesInfo.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_categoryInfo.js'></script> 
	<script type="text/javascript" src="/program/admin/goods/s_classify.js"></script>
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
</head>

<body>
	<h1>添加优惠策略设置</h1>
	
	<form action="/doTradeReg.do" method="post" name="addForm">
	
	<input name="discount_id" id="discount_id" type="hidden" value="<%=model_id%>"/>
  <input name="offer_type" id="offer_type" type="hidden" value="<%=p_type%>"/>
	<table width="100%" cellpadding="0" cellspacing="1" border="0" class="listtab">		
		<tr>
			<td align="right" width="30%">
				 <p style="font-size:16px;font-weight:bold;color:red">优惠条件</p>
			</td>
			<td></td>
		</tr>
		<tr style="display:<% if (p_type.equals("1") || p_type.equals("3") || p_type.equals("4")) out.print(""); else out.print("none");%>;">
			<td align="right" width="30%">
				<% if (p_type.equals("4")) out.print("一年内");%>订单商品总金额满：
			</td>
			<td><input name="spending" id="spending" size="15" maxlength="10" type="text" onKeyUp="if(isNaN(value))this.value=''"/> （元）</td>
		</tr>
		
		<tr style="display:<% if (p_type.equals("2")) out.print(""); else out.print("none");%>;">
			<td align="right" width="30%">
				订单商品总数量满：
			</td>
			<td><input name="number" id="number" size="15" maxlength="10" type="text" onKeyUp="if(isNaN(value))this.value=''"/> （销售计量单位）</td>
		</tr>
		<tr>
			<td align="right" width="30%">
				 <p style="font-size:16px;font-weight:bold;color:red">优惠策略</p>
			</td>
			<td><% if (p_type.equals("5")) out.print("尾货清仓");%></td>
		</tr>
		
		<tr style="display:<% if (p_type.equals("3") || p_type.equals("4")) out.print(""); else out.print("none");%>;">
			<td align="right" width="30%">
				<% if (p_type.equals("4")) out.print("累计返利"); else out.print("打折率");%>
			</td>
			<td><input name="discount" id="discount" size="15" maxlength="10" type="text" onKeyUp="if(isNaN(value))this.value=''"/>% （例：90即9折或者返利90%）</td>
		</tr>
		
		<tr style="display:<% if (p_type.equals("a")) out.print(""); else out.print("none");%>;">
			<td align="right" width="30%">
				运费优惠：
			</td>
			<td><input name="ship_offer" id="ship_offer" size="15" maxlength="10" type="text" onKeyUp="if(isNaN(value))this.value=''"/>元</td>
		</tr>
		
		<tr style="display:<% if (p_type.equals("2")) out.print(""); else out.print("none");%>;">
			<td align="right" width="30%">
				送几个：
			</td>
			<td><input name="send_a_few" id="send_a_few" size="15" maxlength="10" type="text" onKeyUp="if(isNaN(value))this.value=''"/>（相同的订单商品）</td>
		</tr>

		 
		
		<tr style="display:<% if (p_type.equals("1")) out.print(""); else out.print("none");%>;">
			<td align="right" width="30%">
				赠送礼品：
			</td>
			<td>
				<ul style="width:100%;margin:0;">
					<%
						int listsize = 0;
						if (giftlist!=null && giftlist.size()>0)
						{
							listsize = giftlist.size();
							Hashtable giftmap = new Hashtable();
							for(int i=0;i<giftlist.size();i++)
							{
								String gift_id="",gift_name="",img_path="";
								giftmap = (Hashtable)giftlist.get(i);
								if(giftmap.get("gift_id")!=null) gift_id = giftmap.get("gift_id").toString(); 
								if(giftmap.get("gift_name")!=null) gift_name = giftmap.get("gift_name").toString(); 
								img_path =  ti_attachInfo.getFilePathByAttachrootid(gift_id);            
								if(img_path.equals("")) img_path ="/program/admin/images/cpwu.gif";          
					%>
						<li style="width:30%;float:left;padding-left:10px">
							<input type="checkbox" name="checkone<%=i%>" id="checkone<%=i%>" value="<%=gift_id %>" />
							<img src="<%=img_path%>" style="width:100;height:100;border:5px solid #999;"><br>
							<span style="font-size:14px;font-weight:bold;color:blue"><%=gift_name%></span>
						</li>
					<%  
							}
						}
					%>
				</ul>
			</td>
		</tr>		
		<tr>
			<td align="right" width="30%">
				 <p style="font-size:16px;font-weight:bold;color:red">有效时间</p>
			</td>
			<td></td>
		</tr>
		<tr>
			<td align="right" width="30%">
				开始时间：<font color="red">*</font>
			</td>
			<td>
				<input name="start_time" id="start_time" size="20" maxlength="20" type="text"
				 onfocus="WdatePicker({readOnly:true})" />
			</td>
		</tr>
		
		<tr>
			<td align="right" width="30%">
				结束时间：<font color="red">*</font>
			</td>
			<td><input name="end_time" id="end_time" size="20" maxlength="20" type="text" onfocus="WdatePicker({readOnly:true})" /></td>
		</tr>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
				<input type="hidden" name="bpm_id" value="5022" />
				<input type="hidden" name="class_attr" id="class_attr" value="" />
				<input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
				<input type="hidden" name="gift_ids" id="gift_ids" value="" />
				<input name="user_id" id="user_id" value="<%=user_id %>" type="hidden" />
				<input type="button" class="buttoncss" name="tradeSub" value="提交" onclick="return checkSub('addForm');"/>&nbsp;&nbsp;
				<input type="button" class="buttoncss" name="tradeRut" value="返回" onclick="window.history.go(-1);"/>
			</td>
		</tr>
	</table>
	</form>
</body>

</html>
